<template>
    <div class="txt">
        <mt-header title="记事本">
            <mt-button icon="more" slot="right"></mt-button>
        </mt-header>
        <input type="text" v-model="Things" @keyup.enter="save" >
        <button class="btn" @click="save">提交</button>
         <mt-header title="未完成事件"> </mt-header>
         <ul>
            <li v-for="(item,index) in ThingsList" :key="index" v-show="item.type==1">
                <span>{{item.name}}</span>
                <button @click="finish(index)">完成</button>
                <hr color="#ddd">
            </li>
        </ul>
           <mt-header class="tit" title="已完成"></mt-header>
        <ul class="done">
            <li v-for="(item,index) in ThingsList" :key="index"  v-show="item.type==2">
                <span>{{item.name}}</span>
            </li>
        </ul>

    <br>
    <br>
</div>
</template>

<script>
import { Header } from 'mint-ui';
export default {
    data(){
        return{
            Header,
            Things:'',
            ThingsList:[]
            // todoThings:['吃饭','逛街'],
            // dobeThings:['爬山']
        }
    },
    methods:{
        // 新增代办事件
        save(){
            if(this.Things){
                this.ThingsList.push({
                    name:this.Things,
                    type:1
                    // 1：未完成 2已完成
                });
                this.Things=''
                
            }
            
        },
        // 完成该事件
        finish(index){
            // this.dobeThings.push( this.todoThings[index])
            // this.todoThings.splice(index,1)
            this.ThingsList[index].type = 2
        }
    }
}
</script>

<style scoped>
    .txt{
        width: 70%;
       margin: 0 auto;
    }
    .txt input{
        display: block;
        width: 90%;
        height: 30px;
        margin-top: 20px;
        margin-bottom: 10px;
        
    }
     .btn{
        float: right;
        margin-top: -45px;
        width: 8%;
        height: 35px;
        background-color: #409EFF;
        border: none
     }
     .btn{
         margin-left: 10px;
     }
     ul{
         list-style: none;
     }
     .done{
         color: darkgrey;
         text-decoration: line-through;
     }

</style>